load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "optimizor",
    srcs = [
        "optimize_trace.go",
        "plan_replayer.go",
        "statistics_handler.go",
    ],
    importpath = "github.com/pingcap/tidb/pkg/server/handler/optimizor",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/domain",
        "//pkg/domain/infosync",
        "//pkg/infoschema",
        "//pkg/meta/model",
        "//pkg/parser/model",
        "//pkg/parser/mysql",
        "//pkg/server/handler",
        "//pkg/session",
        "//pkg/sessionctx/variable",
        "//pkg/statistics/handle",
        "//pkg/statistics/handle/util",
        "//pkg/table",
        "//pkg/types",
        "//pkg/util",
        "//pkg/util/logutil",
        "//pkg/util/replayer",
        "@com_github_burntsushi_toml//:toml",
        "@com_github_gorilla_mux//:mux",
        "@com_github_pingcap_errors//:errors",
        "@com_github_tikv_client_go_v2//oracle",
        "@org_uber_go_zap//:zap",
    ],
)

go_test(
    name = "optimizor_test",
    timeout = "short",
    srcs = [
        "main_test.go",
        "optimize_trace_test.go",
        "plan_replayer_test.go",
        "statistics_handler_test.go",
    ],
    flaky = True,
    shard_count = 5,
    deps = [
        ":optimizor",
        "//pkg/config",
        "//pkg/domain",
        "//pkg/kv",
        "//pkg/metrics",
        "//pkg/parser/model",
        "//pkg/server",
        "//pkg/server/internal/testserverclient",
        "//pkg/server/internal/testutil",
        "//pkg/server/internal/util",
        "//pkg/session",
        "//pkg/statistics/handle/util",
        "//pkg/store/mockstore/unistore",
        "//pkg/testkit",
        "//pkg/testkit/testsetup",
        "//pkg/util/replayer",
        "//pkg/util/topsql/state",
        "@com_github_burntsushi_toml//:toml",
        "@com_github_go_sql_driver_mysql//:mysql",
        "@com_github_gorilla_mux//:mux",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_stretchr_testify//require",
        "@com_github_tikv_client_go_v2//oracle",
        "@com_github_tikv_client_go_v2//tikv",
        "@org_uber_go_goleak//:goleak",
    ],
)
